/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Interface;

import javax.print.attribute.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

/**
 *
 * @author linton
 */
public class MeuDocument extends PlainDocument {

    public void insertString(int offs, String str, AttributeSet a)
            throws BadLocationException
    {
        String texto = getText(0, getLength());
        if(texto.length() < 7) {
            remove(0, getLength());
            StringBuffer strBuf = new StringBuffer(texto.replaceAll(",", "")+ str);
            if(strBuf.length() < 3) strBuf.insert(0, ",");
            else strBuf.insert(strBuf.length() - 2, ",");
            super.insertString(0, strBuf.toString(),(javax.swing.text.AttributeSet) a);
        }
    }
}


